﻿<%@ WebHandler Language="C#" Class="GetBc" %>

using System;
using System.Web;
using System.Data;
using Newtonsoft.Json;

public class GetBc : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string pid = StringHelper.SafeSqlInput(context.Request.QueryString["pid"]);
        string tstartdate = StringHelper.SafeSqlInput(context.Request.QueryString["startdate"]);
        string tenddate = StringHelper.SafeSqlInput(context.Request.QueryString["enddate"]);
        DBHelper db = new DBHelper();

        DataTable dt;

        string sql = "";
        if (pid != "" && tstartdate != "" && tenddate != "")
        {

            sql = "select * from v_A_Attendance where userbh='" + pid + "' and rq>='" + tstartdate + "' and rq<='" + tenddate + "' and type=1 and [state]<>1 order by rq";
            dt = db.getList(sql);
            context.Response.ContentType = "application/json";
            context.Response.Write(JsonConvert.SerializeObject(dt));
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}